package com.lw.question03;

/**
 * @author LW
 * @2020/9/14 10:47
 */
public class 分数递加3 {

    public static void t3() {
        double a = 2;
        double b = 1;
        double c = 0;
        double sum = 0;
        for (int i = 0; i < 20; i++) {
            sum += a / b;
            System.out.println(sum);
            c = b;
            b = a;
            a = b + c;
        }
        System.out.println(sum);
    }

    public static void main(String[] args) {
        t3();
    }


    /**
     * 数组的除法都是            整数！！！！！！！！！！！！！！！！！！！！
     * public static void main(String[] args) {
     *         int[] a = new int[20];
     *         int[] b = new int[20];
     *         double[] c = new double[20];
     *         a[0] = 2;
     *         b[0] = 1;
     *         double s = 0;
     *         for (int i = 1; i < a.length; i++) {
     *             a[i]=a[i-1]+b[i-1];
     *             System.out.println("a="+a[i]);
     *             b[i]=a[i-1];
     *             System.out.println("b="+b[i]);
     *             c[0]=a[0]/b[0];
     *             c[i]=a[i]/b[i];
     *             System.out.println("c="+c[i]);
     *             s+=c[i];
     *         }
     *         s+=c[0];
     *         System.out.println("s="+s);
     *     }
     * @param args
     */

}
